<template>
  <div class="container">
    <Breadcrumb :items="['menu.clock']" />
    <a-card class="general-card" :title="t('menu.clock')">
      <!-- <a-calendar v-model="store.value" @change="store.change" />
      select: {{ store.value }} -->
      <a-spin :loading="loading" style="width: 100%">
        <FullCalendar ref="myCalendar" :options="store.calendarOptions" />
      </a-spin>
      <a-modal
        v-model:visible="store.status"
        :title="`${store.form?.id ? '编辑任务' : '新建任务'}`"
        draggable
        unmount-on-close
        @before-ok="store.handleBeforeOk"
        @close="$refs.formRef.resetFields()"
        @open="store.open(focusRef, formRef)"
        width="50%"
      >
        <a-form ref="formRef" :model="store.form" :rules="store.rules">
          <a-form-item field="title" label="任务标题">
            <a-input
              ref="focusRef"
              v-model="store.form.title"
              placeholder="请输入任务标题"
            />
          </a-form-item>
          <a-form-item field="desc" label="任务介绍">
            <a-textarea
              v-model="store.form.desc"
              placeholder="请输入任务标题"
              show-word-limit
              allow-clear
              auto-size
            />
          </a-form-item>
          <a-form-item field="score" label="积分奖励">
            <a-input-number
              v-model.number="store.form.score"
              placeholder="请输入任务标题"
              :default-value="0"
            />
          </a-form-item>
          <a-form-item field="start_time" :label="`开始时间`">
            <a-date-picker
              v-model="store.form.start_time"
              placeholder="请选择开始时间"
              style="width: 100%"
              show-time
            />
          </a-form-item>
          <a-form-item field="end_time" :label="`结束时间`">
            <a-date-picker
              v-model="store.form.end_time"
              placeholder="请选择开始时间"
              style="width: 100%"
              show-time
            />
          </a-form-item>
          <a-form-item field="student_id" label="学生">
            <a-tree
              :checkable="true"
              v-model:checked-keys="store.form.student_id"
              :data="store.options.squad"
              show-line
              :default-expand-all="false"
            />
          </a-form-item>
        </a-form>
      </a-modal>
    </a-card>
  </div>
</template>

<script lang="ts" setup>
  import FullCalendar from '@fullcalendar/vue3';

  import {
    computed,
    ref,
    reactive,
    watch,
    nextTick,
    onMounted,
    defineComponent,
  } from 'vue';
  import { useI18n } from 'vue-i18n';

  import { Pagination } from '@/types/global';
  import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface';
  import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
  import cloneDeep from 'lodash/cloneDeep';
  import Sortable from 'sortablejs';
  import { Divider, Message, Modal } from '@arco-design/web-vue';
  import { useClockStore } from '@/store/index';
  import useLoading from '@/hooks/loading';
  const store = useClockStore();
  const formRef = ref();
  const focusRef = ref();
  const { loading, setLoading } = useLoading(true);

  watch(
    () => store.data,
    () => {
      setLoading(false);
    }
  );
  const { t } = useI18n();
  onMounted(() => {
    store.formRef = formRef.value;
  });
</script>

<style scoped lang="less">
  .container {
    padding: 0 20px 20px 20px;
  }
  :deep(.arco-table-th) {
    &:last-child {
      .arco-table-th-item-title {
        margin-left: 16px;
      }
    }
  }
  .action-icon {
    margin-left: 12px;
    cursor: pointer;
  }
  .active {
    color: #0960bd;
    background-color: #e3f4fc;
  }
  .setting {
    display: flex;
    align-items: center;
    width: 200px;
    .title {
      margin-left: 12px;
      cursor: pointer;
    }
  }
</style>
